Size the perspective viewport from the scene bounding radius - #88
Merged
Conversation
_scene_extent is interactive-only (the static render path autoscales via matplotlib and never calls it), so its "scene reaches the eye plane" warning only ever accompanies a render the user can already see. The projection's own project_camera warning covers the degenerate case on both the interactive and headless paths, with better per-frame timing. Remove the redundant warning, its now-unused imports, and its tests. Also add an enclosure test that pins the real contract (the viewport encloses the outermost atom at its worst rotation, not merely exceeds the un-magnified radius) and an empty-scene magnification test, and trim the known-limitation comment to observable behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_scene_extentwidens the interactive viewport under perspective by the worst-case magnification, but it computed that worst case from atom centre distances alone. The outermost renderable point can be a unit-cell corner or a large atom's surface (centre + display radius) sitting farther out, so a big cell or atom rotating towards the eye magnified more than the viewport was sized for and clipped at the edge.max_extent— the scene's true bounding radius, which already includes atom surfaces and cell corners — rather than the maximum atom-centre distance. This is a conservative, rotation-invariant bound: any point at distancedprojects to a radius no larger thand * scale(d), so it over-sizes rather than clips. Orthographic output is unchanged, because its magnification is always1.0.assert isinstancedowncast it only existed to feed._scene_extentis interactive-only and off the static render path, so the change is pinned by unit tests rather than the golden harness; each behavioural test fails on the pre-fix code.Out of scope, to follow separately: the viewport's zoom recompute on frame navigation, and the unbounded magnification as the eye nears the bounding sphere (recorded as a known limitation, with a near-plane-clipping rework the honest fix rather than a magic-threshold clamp).